/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Admin
 * Date: 2022-12-05
 * Time: 18:50
 */
import java.util.*;

public class Demo1 {
    static int[][] array = new int[20][20];
    static int count;

    public static void func(int x,int y,int m,int n) {
        if(x < 0 || x >= m || y < 0 || y >= n || array[x][y] == 1 ) {
            return;
        }

        array[x][y] = 1;
        count++;
        func(x - 1,y,m,n);
        func(x + 1,y,m,n);
        func(x,y - 1,m,n);
        func(x,y + 1,m,n);
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        while(scan.hasNext()) {
            int m = scan.nextInt();
            int n = scan.nextInt();
            scan.nextLine();

            int x = 0;
            int y = 0;
            for(int i = 0; i < m; i++) {
                String str = scan.nextLine();
                for(int j = 0; j < n; j++) {
                    char ch = str.charAt(j);
                    if(ch == '@') {
                        x = i;
                        y = j;
                    }else {
                        if(ch == '#'){
                            array[i][j] = 1;
                        }
                    }
                }
            }
            func(x,y,m,n);
            System.out.println(count);
            count = 0;
            for(int i = 0; i < m; i++) {
                for(int j = 0; j < n; j++) {
                    array[i][j] = 0;
                }
            }
        }
    }
}
